<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<head lang="en">
    <th:block th:include="include :: header('添加角色')"/>
</head>
<body>
<form class="layui-form" style="padding: 10px" lay-filter="form">

    <div class="layui-form-item">
        <label class="layui-form-label">资源名称</label>
        <div class="layui-input-block">
            <input type="text" id="resuorceName" name="resuorceName"
                   class="layui-input" placeholder="请输入资源名称">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">资源链接</label>
        <div class="layui-input-block">
            <input type="text" id="linkUrl" name="linkUrl"
                   class="layui-input" placeholder="请输入资源链接">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">权限字符串</label>
        <div class="layui-input-block">
            <input type="text" id="resourceCode" name="resourceCode"
                   class="layui-input" placeholder="请输入权限字符串">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">资源类型</label>
        <div class="layui-input-block">
            <input type="text" id="resourceType" name="resourceType"
                   class="layui-input" placeholder="请输入资源类型">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">父级ID</label>
        <div class="layui-input-block">
            <input type="text" id="parentId" name="parentId"
                   class="layui-input" placeholder="请输入父级ID">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-block">
            <input type="text" id="sort" name="sort"
                   class="layui-input" placeholder="请输入排序">
        </div>
    </div>
    <input type="hidden" id="id" name="id">
    </div>
    <div style="display: none">
        <button class="layui-btn" lay-submit lay-filter="*" id="submit">立即提交</button>
    </div>
</form>
</body>
<th:block th:include="include :: footer"/>
<script type="text/javascript">

    //从父层获取值，json是父层的全局js变量。eval是将该string类型的json串变为标准的json串
    layui.use(['form'], function () {
        var form = layui.form;
        if (parent.json) {
            var parent_json = parent.json;
            form.val("form", {
                "id": parent_json.id
                , "resuorceName": parent_json.resuorceName
                , "linkUrl": parent_json.linkUrl
                , "resourceType": parent_json.resourceType
                , "resourceCode": parent_json.resourceCode
                , "parentId": parent_json.parentId
                , "delFlg": parent_json.delFlg
                , "CREATER": parent_json.CREATER
                , "createTime": parent_json.createTime
                , "UPDATOR": parent_json.UPDATOR
                , "sort": parent_json.sort
                , "icon": parent_json.icon
            })
        }
        form.render("select");                                // 刷性select，显示出数据
        form.on('submit(*)', function (data) {
            config.commPost("/ht/sysResourceAdd.json", data.field, function (data, info) {
                parent.config.tableRefresh();
                parent.config.closeLayer(info);
            })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

    })

    function ApplicationSave() {
        document.getElementById("submit").click();
    }
</script>
</html>

